<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
<#include "../head.html"/>
<script type="text/javascript">
 function addTypeValue(){
 	var table = $("table:eq(1)");
	var tr = $("table:eq(1) tr:eq(0)");
 	var cTr = tr.clone(true);
	$("input[name='btn_save']",cTr).attr("disabled","");
	cTr.appendTo(table);
 }
 
 function saveType(){
 	 //var isKey = $("input[name='isKey']:checked",$(obj).parent().parent()).val(); 
	 //var isInput = $("input[name='isInput']:checked",$(obj).parent().parent()).val(); 
 	var name = $("#typeName").val();
	if(name == ''){
		return ;
	}
 	$.post("save_type.do", {typeName: name},
	   function(data){
		 $("#typeId").val(data);	
		  $("#typeName").attr("readonly",true);
	  }
	);
 }
 
 function saveTypeValue(obj){
	 var typeValue = $("input[name='typeValue']",$(obj).parent().parent()).val(); 
	 var orderNum = $("input[name='orderNum']",$(obj).parent().parent()).val();
	 var typeId =  $("#typeId").val();
	 if(typeId == ''){
	 	alert("类型名称不能为空");
		return ;
	 }
	var dataStr = "typeValue=" + typeValue +"&orderNum=" + orderNum +"&typeId=" + typeId;
	$.ajax({
	   type: "POST",
	   url: "save_typeval.do",
	   data: dataStr,
	   success: function(msg){
	     $("input[name='btn_save']",$(obj).parent().parent()).attr("disabled","disabled");
	   }
	});
	
 }
</script>
</head>
<body>
 
<div class="box-positon">
	<div class="rpos"><@s.m "global.position"/>: <@s.m "channel.function"/> - <@s.m "global.add"/></div>
	<form class="ropt">
		<input type="submit" value="返回列表" onclick="this.form.action='v_list.do'" class="return-button"/>
		<input type="button" value="添加类型值" onclick="addTypeValue()" class="return-button"/>
	</form>
	<div class="clear"></div>
</div>

<div class="body-box">
	<div class="body-box">
	 	<@p.form id="jvForm" action="v_send.do" labelWidth="10">
			<@p.text colspan="2" width="50" label="类型名称" name="typeName" id="typeName" required="true" class="required" maxlength="100" onblur="saveType()"/>
			<@p.radio value="true" list={"true":"是","false":"否"} label="是否关键字" name=Key />
			<input  type="hidden" name="typeId" id="typeId"/>
		</@p.form>
		
		<@p.form id="jvForm" action="v_send.do" labelWidth="10">
					
					<td>类型值</td> 
					<td>
						 <input type="text" name="typeValue" value="1" />
					</td>
					<td>排序</td> 
					<td>
						 <input type="text" name="orderNum" value="1" />
					</td>
					<td id="1">
						
						 <input type="button" name="btn_save" value="确定" onclick="saveTypeValue(this)"/>
					</td>
				
		</@p.form>
	</div>
</div>
</body>
</html>